home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Games / ms-0.07 / lib / ms_ipc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-27  |  2.3 KB  |  101 lines

  1. /* ms_ipc.h - layout of messages passed between Mama and the slave, */
  2. /*            and other network stuff */
  3. /* Copyright (C) 1990-1993 Andreas Gustafsson */
  4.  
  5. #ifndef _ms_ipc_h
  6. #define _ms_ipc_h
  7.  
  8. #include "inet.h"
  9.  
  10. /* update these whenever changes have been made to the layout of */
  11. /* any of the structures defined below */
  12.  
  13. #define VERSION        5    /* major version */
  14. #define DATA_FORMAT     7    /* minor version (name is historical) */
  15.  
  16. /* miscellaneous magic constants */
  17.  
  18. #define MAX_DATAGRAM    8192    /* maximum datagram size */
  19. #define MAGIC         0x9872    /* magic number */
  20. #define DEFAULT_PORT    9359    /* default UDP port */
  21.  
  22. /* message types */
  23.  
  24. #define WHIP_MESSAGE 0
  25. #define REPLY_MESSAGE 1
  26. #define WHO_R_U_MESSAGE 2
  27. #define I_AM_MESSAGE 3
  28.  
  29. typedef struct
  30. { uint16 magic;        /* magic number */
  31.   uint16 type;        /* packet type */
  32.   uint16 version;    /* protocol version */
  33.   uint16 format;     /* data format (= minor protocol version) */
  34. } MessageHeader;
  35.  
  36. typedef struct
  37. { uint16 pid;        /* process id of requesting process */
  38.   uint16 seq;        /* sequence number */
  39.   uint16 chunk_no;    /* chunk number within current sequence */
  40.   uint16 slave_no;    /* index into the client's slave table */
  41. } MessageId;
  42.  
  43.  
  44. /* C doesn't support zero-sized arrays; it's a shame. */
  45. #ifdef __GNUCC__
  46. #define VARIES 0
  47. #else
  48. #define VARIES 1
  49. #endif
  50.  
  51. /* Work request message */
  52. typedef struct
  53. { MessageHeader header;
  54.   MessageId id;
  55.   char data[VARIES];        /* this really is a ms_job, but pretend */
  56. } WhipMessage;            /* not to know that */
  57.  
  58.  
  59. /* Reply message */
  60. /* the reply message need not contain any corner, delta, or rectangle field */
  61. /* because these are saved in the chunk */
  62. typedef struct
  63. { MessageHeader header;
  64.   MessageId id;
  65.   uint32 mi_count;
  66.   union
  67.   { uint8 chars[1];
  68.     uint16 shorts[1];
  69.   } data;
  70. } ReplyHeader;
  71.  
  72. /* Slave PID inquiry message */
  73. typedef struct
  74. { MessageHeader header;
  75.   uint16 port;
  76.   uint16 pad;
  77. } WhoAreYouMessage;
  78.  
  79. /* Reply to PID inquiry */
  80. typedef struct
  81. { MessageHeader header;
  82.   uint16 pid;
  83.   uint16 pad;
  84. } IAmMessage;
  85.  
  86. /* Used when we don't know the message type yet */
  87. typedef struct
  88. { MessageHeader header;
  89. } GenericMessage;
  90.  
  91. typedef union
  92. { char c[MAX_DATAGRAM];
  93.   GenericMessage generic;
  94.   ReplyHeader reply;
  95.   WhipMessage whip;
  96.   WhoAreYouMessage who;
  97.   IAmMessage iam;
  98. } Message;
  99.  
  100. #endif /* _ms_ipc_h */
  101.